#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define pb push_back
#define lowbit(x) (x&(-x))
#define m_p make_pair
#define P pair<int,int>
typedef long long ll;
ll d[100005],v[100005],a[100005];
int p[100005];
ll l,V;
bool check(int i,int j){  //the i-th car chaosu at j?
    if(d[i]>p[j]) return 0;
    ll s=p[j]-d[i];
    if(a[i]<0){
        if(v[i]*v[i]<-2*a[i]*s) return 0;
    }
    if(v[i]*v[i]+2*a[i]*s>V*V) return 1;
    return 0;
}
bool cmp(P x,P y){
    return x.sc<y.sc;
}
void solve(){
    int n,m;cin>>n>>m>>l>>V;
    for(int i=0;i<n;i++) cin>>d[i]>>v[i]>>a[i];
    for(int i=0;i<m;i++) cin>>p[i];
    vector<P> inter;
    int sum=0;
    for(int i=0;i<n;i++){
        if(a[i]<=0){
            int pl=lower_bound(p,p+m,d[i])-p;
            if(pl<m&&check(i,pl)){
                int l=pl,r=m-1,res=pl;
                while(l<=r){
                    int mid=(l+r)/2;
                    if(check(i,mid)){
                        res=mid;
                        l=mid+1;
                    }
                    else r=mid-1;
                }
                inter.pb(m_p(pl,res));
                //cout<<i<<" "<<pl<<" "<<res<<endl;
                sum++;
            }
        }
        else{
            if(d[i]<=p[m-1]&&check(i,m-1)){
                int l=0,r=m-1,res=m-1;
                while(l<=r){
                    int mid=(l+r)/2;
                    if(check(i,mid)){
                        res=mid;
                        r=mid-1;
                    }
                    else l=mid+1;
                }
                inter.pb(m_p(res,m-1));
                //cout<<i<<" "<<res<<" "<<m-1<<endl;
                sum++;
            }
        }
    }
    int ans=0;
    sort(inter.begin(),inter.end(),cmp);
    int mx=-1;
    for(int i=0;i<inter.size();i++){
        int l=inter[i].fr,r=inter[i].sc;
        if(mx<l){
            mx=r;
            ans++;
        }
    }
    cout<<sum<<" "<<m-ans<<endl;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;cin>>t;
    while(t--) solve();
    return 0;
}